package com.bob.clan.wxconnector.config;


import com.bob.clan.wxconnector.interceptor.OperateLogInterceptor;
import com.bob.clan.wxconnector.interceptor.SecurityInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @program: cloudfloating
 * @description: 通过实现WebMvcConfigurer登陆拦截器
 * @author: qx.zhang
 * @create: 2021-03-19 10:14
 **/
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Bean
    public SecurityInterceptor commonInterceptor(){
        return new SecurityInterceptor();
    }

    @Bean
    public OperateLogInterceptor operateLogInterceptor(){
        return new OperateLogInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(operateLogInterceptor()).addPathPatterns("/**")
                .excludePathPatterns("/css/**","/font/*","/images/**","/js/**","/*.html","/*.ttf","/*.txt");
        registry.addInterceptor(commonInterceptor()).addPathPatterns("/**")
                .excludePathPatterns("/logInController/login","/sys/dologin","/sys/dologout","/error","/","/favicon.ico","/css/**","/js/**","/images/**","/fonts/**","/static/ueditor/**");
    }
}
